package com.mes.cloud.utils;

public abstract class AssertUtils {
    public static void notNull(Object expression, String message) throws Exception {
        if (expression == null) {
            throw new Exception(message);
        }
    }

    public static void notNull(Object expression) throws Exception {
        notNull(expression, "[Assertion failed] - this argument is required; it must not be null");
    }

    public static void notEmpty(String expression, String message) throws Exception {
        if (StringUtils.isBlank(expression)) {
            throw new Exception(message);
        }
    }

    public static void notEmpty(String expression) throws Exception {
        notNull(expression, "[Assertion failed] - this argument is required; it must not be empty");
    }

    public static void isEqual(Object expression1, Object expression2, String message)
            throws Exception {
        if (expression1 == null || expression2 == null || !expression1.equals(expression2)) {
            throw new Exception(message);
        }
    }

    public static void lteLength(String expression, int length, String message) throws Exception {
        if (length > 0) {
            if (StringUtils.isNotBlank(expression) && expression.length() > length) {
                throw new Exception(message);
            }
        }
    }



}